package org.redis.cluster.test.transport.redis;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;
import org.redis.cluster.processor.RedisReplyProcessor;
import org.redis.cluster.redis.processor.RedisBulkReplyProcessor;
import org.redis.cluster.redis.processor.RedisErrorReplyProcessor;
import org.redis.cluster.redis.processor.RedisMultipleBulkReplyProcessor;
import org.redis.cluster.redis.processor.RedisNumberReplyProcessor;
import org.redis.cluster.redis.processor.RedisStatusReplyProcessor;
import org.redis.cluster.redis.transport.RedisReply;
import org.redis.cluster.redis.transport.reply.RedisBulkReply;
import org.redis.cluster.redis.transport.reply.RedisErrorReply;
import org.redis.cluster.redis.transport.reply.RedisMultipleBulkReply;
import org.redis.cluster.redis.transport.reply.RedisNumberReply;
import org.redis.cluster.redis.transport.reply.RedisStatusReply;

public class RedisMultipleBulkReplyProcessorTester {

	@Test
	public void test() {
		RedisMultipleBulkReplyProcessor processor=new RedisMultipleBulkReplyProcessor();
		processor.setReplyProcessorMapping(new HashMap<Class<? extends RedisReply>,RedisReplyProcessor>(){{
			put(RedisErrorReply.class,new RedisErrorReplyProcessor());
			put(RedisNumberReply.class,new RedisNumberReplyProcessor());
			put(RedisStatusReply.class,new RedisStatusReplyProcessor());
			put(RedisBulkReply.class,new RedisBulkReplyProcessor());
			put(RedisMultipleBulkReply.class,new RedisMultipleBulkReplyProcessor());
		}});
		
		List<RedisReply> list=new ArrayList<RedisReply>();
		list.add(null);
		list.add(new RedisNumberReply(1));
		list.add(new RedisStatusReply("test status"));
		RedisMultipleBulkReply reply=new RedisMultipleBulkReply(list);
		byte result[]=processor.process(reply);
		System.out.println(new String(result));
		Assert.assertEquals("*3\r\n$-1\r\n:1\r\n+test status\r\n", new String(result));
	}
}